package com.burgeon.backend.SHOP.controller;


import com.burgeon.backend.SHOP.entity.VipEmployeeVo;
import com.burgeon.backend.SHOP.service.AppChatService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;


@RestController
@RequestMapping("shop/chat")
public class AppChatController extends BaseController {
    private final static Log logger = LogFactory.getLog(AppChatController.class);
    @Autowired
    private AppChatService appChatService;

    //判断会员是否注册/绑定 (用log接口)
    //已注册/绑定 判断会员是否绑定导购 (走下部分流程)
    //未注册/绑定 走注册流程 (绑定erp注册流程)

    //openid判断会员是否绑定导购
    //未绑定: 显示会员所在门店导购 头像 姓名 性别 电话
    @RequestMapping("isEmp")
    public ResponseResult<VipEmployeeVo> IsVipByOpenId(HttpSession session){
        String openid = session.getAttribute("app_openid").toString();
        String token = session.getAttribute("token").toString();
        logger.info("token:"+token);
        logger.info("openid:"+openid);
        VipEmployeeVo data = appChatService.IsEmpByOpenId(openid,token);

        return new ResponseResult<>(SUCCESS,data );
    }

    //选择导购绑定
    @RequestMapping("chooseEmp")
    public ResponseResult<HashMap> ChooseEmp(String id, HttpSession session){
        String openid = session.getAttribute("app_openid").toString();
        String token = session.getAttribute("token").toString();
        HashMap data = appChatService.ChooseEmp(openid,id,token);
        return new ResponseResult<>(SUCCESS,data );
    }

    // 开始聊天






}
